//#include<stdio.h>
//
//int main()
//{
//	int x = 1;
//	char* p = (char*)&x;
//	printf("%d", *p);
//
//
//
//}
#include <iostream>
#include<vector>
using namespace std;
bool real(int y)
{
	for (int i = 2; i <=sqrt(y); i++)
	{
		if (y % i == 0)
			return false;


	}

	return true;
}
bool count(int x)
{
	vector<int>ret;
	while (x)
	{
		ret.push_back(x % 10);
		x /= 10;
	}
	for (int i = 0; i < ret.size(); i++)
	{
		for (int j = 0; j < ret.size(); j++)
		{
			if (i!=j&&ret[i] != 0 && real(ret[i] * 10 + ret[j]))
			{
				return true;
			}


		}
	}

	return false;



}
int main() {
	int a, b;
	cin >> a >> b;
	int num = 0;
	for (int i = a; i <= b; i++)
	{
		if (count(i))
			num++;
	
	
	}
	
	cout << num;




}
class Solution {
public:
	vector<int> plusOne(vector<int>& digits) {
		int m = digits.size() - 1;
		string str1 = "1";
		string str2;
		int sum = 0;
		for (auto e : digits)
		{
			str2 += e + '0';
		}


		int x = str1.size() - 1;
		int y = str2.size() - 1;
		int ret = 0;
		string out;
		while (x >= 0 || y >= 0 || ret > 0)
		{
			if (x >= 0)
				ret += str1[x--] - '0';
			if (y >= 0)
				ret += str2[y--] - '0';


			out += ret % 10 + '0';
			ret /= 10;
		}
		reverse(out.begin(), out.end());
		vector<int>st;
		for (auto e : out)
		{
			st.push_back(e - '0');


		}

		return st;

	}
}; class Solution {
public:
	string longestPalindrome(string s) {
		int m = s.size();
		int lenth = 0;
		vector<vector<bool>>dp(m, vector<bool>(m));
		int memi;
		for (int i = m - 1; i >= 0; i--)
		{
			for (int j = i; j < m; j++)
			{
				if (s[i] == s[j])
				{

					dp[i][j] = i + 1 < j ? dp[i + 1][j - 1] : true;
				}
				if (dp[i][j] && j - i + 1 > lenth)
				{
					lenth = j - i + 1;
					memi = i;
				}

			}
		}

		return s.substr(memi, lenth);













	}
};/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
	ListNode* oddEvenList(ListNode* head) {
		if (head == nullptr)
			return nullptr;
		ListNode* odd = head;
		ListNode* evenhead = head->next;
		ListNode* even = evenhead;
		while (even != nullptr && even->next != nullptr)
		{
			odd->next = even->next;
			odd = odd->next;
			even->next = odd->next;
			even = even->next;

		}

		odd->next = evenhead;
		return head;











	}
};